//
//  HomeTableViewCell.m
//  ZJControlsClass
//
//  Created by apple on 2024/10/27.
//

#import "HomeTableViewCell.h"


@interface HomeTableViewCell()

@property (nonatomic,strong) UIImageView * iconImg;
@property (nonatomic,strong) UILabel * msgLabel;
@property (nonatomic,strong) UILabel * timeLabel;


@end



@implementation HomeTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self congUI];
        
    }
    return self;
}

-(void)congUI{
    [self.contentView addSubview:self.iconImg];
    [self.contentView addSubview:self.msgLabel];
    [self.contentView addSubview:self.timeLabel];
    
    [self.iconImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).with.offset(ALIGN_WIDTH_PT(12));
        make.top.equalTo(self.contentView).with.offset(ALIGN_HEIGHT_PT(10));
        make.height.equalTo(@(ALIGN_HEIGHT_PT(85)));
        make.width.equalTo(@(ALIGN_WIDTH_PT(114)));
    }];
    
    [self.msgLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconImg.mas_right).with.offset(ALIGN_WIDTH_PT(10));
        make.top.equalTo(self.iconImg.mas_top);
        make.right.equalTo(self.contentView).with.offset(-ALIGN_WIDTH_PT(12));
    }];
    
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.msgLabel.mas_left);
        make.bottom.equalTo(self.iconImg.mas_bottom).with.offset(-ALIGN_HEIGHT_PT(10));
        make.right.equalTo(self.msgLabel.mas_right);
    }];
    
    
}

-(void)setModel:(HomeShowNewsModel *)model{
    _model = model;
    [self.iconImg sd_setImageWithURL:[NSURL URLWithString:self.model.articleCover] placeholderImage:[UIImage imageNamed:@"banner"]];
    self.msgLabel.text = [NSString stringWithFormat:@"%@",self.model.articleName.length > 0 ? self.model.articleName : @""];
    self.timeLabel.text = [NSString stringWithFormat:@"%@",self.model.publishTime];
    
}


#pragma mark -- 懒加载
-(UIImageView *)iconImg{
    if (!_iconImg) {
        _iconImg = [UIImageView new];
        _iconImg.layer.cornerRadius = 10;
        _iconImg.layer.masksToBounds = YES;
    }
    return _iconImg;
}

-(UILabel *)msgLabel{
    if (!_msgLabel) {
        _msgLabel = [UILabel new];
        _msgLabel.text = @"银川机场单日旅客吞吐量超3.6万 人次 迎来暑运开门红";
        _msgLabel.numberOfLines = 2;
        _msgLabel.textColor = [UIColor blackColor];
        _msgLabel.font = FONT15;
    }
    return _msgLabel;
}

-(UILabel *)timeLabel{
    if (!_timeLabel) {
        _timeLabel = [UILabel new];
        _timeLabel.textColor = COLOR_RGB(153, 153, 153);
        _timeLabel.textAlignment = NSTextAlignmentLeft;
        _timeLabel.font = FONT11;
        _timeLabel.text = @"2024.04.25";
    }
    return _timeLabel;
}








+(NSString *)cell{
    return @"HomeTableViewCell";
}



@end
